﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.PaintColorTableAdapters;
using DAL.DateSet;
using DAL;
namespace BLL.Wrapper
{
    public class PaintColorWrapper : PaintColorTableAdapter
    {
        public PaintColor.PaintColorDataTable getall()
        {
            return GetData();
        }

        public void addARecord(PaintColor.PaintColorRow row)
        {
            Insert(row.colorSystemID, row.paintColorName, row.paintColorNum, row.paintColorCreator, row.paintCreateDate);
        }

        public void deleteByID(int id)
        {
            string sql = "delete from ModifyRecord where paintColorID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void updateARecord(PaintColor.PaintColorRow row)
        {
            PaintColor.PaintColorDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["paintColorID"]) == row.paintColorID)
                {
                    table.Rows[i]["colorSystemID"] = row.colorSystemID;
                    table.Rows[i]["paintColorName"] = row.paintColorName;
                    table.Rows[i]["paintColorNum"] = row.paintColorNum;
                    table.Rows[i]["paintColorCreator"] = row.paintColorCreator;
                    table.Rows[i]["paintCreateDate"] = row.paintCreateDate;
                    break;
                }
            }
            Update(table);
        }
    }
}
